﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SanQiOther.Models;
using System.Data.Entity;

namespace SanQiOther.Controllers
{
    public class InsuranceController : Controller
    {
        private RewardDbContext db = new RewardDbContext();
        // GET: Insurance
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult Index_R()
        {
            var member = db.v_member.Where(r => r.isbx == false && r.islz == false );
            return View(member.ToList());
        }
        public ActionResult Index_L()
        {
            var member = db.v_member.Where(r => r.isbx == false && r.islz == true);
            return View(member.ToList());
        }
        public ActionResult Detail(int id)
        {
            v_member member = db.v_member.FirstOrDefault(r => r.id == id);
            return View(member);
        }

        [HttpPost]
        public ActionResult Detail(member Member)
        {

            SanQiOther.Models.member Member_New = new member();
            Member_New = db.member.Find(Member.id);
            if (ModelState.IsValid)
            {
                db.Entry(Member_New).State = EntityState.Modified;
                Member_New.isbx = Member.isbx;
                db.SaveChangesAsync();
                return RedirectToAction("Index");
            }
            return View();
        }
    }
}